package top.tangyh.lamp.care.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.tangyh.basic.base.R;
import top.tangyh.lamp.care.service.BDevBindService;
import top.tangyh.lamp.care.service.BPatientService;
import top.tangyh.lamp.care.vo.query.PatientBindInputVO;
import top.tangyh.lamp.care.vo.query.PatientHomePageQueryVO;
import top.tangyh.lamp.care.vo.result.FuerInpatientInfoResult;
import top.tangyh.lamp.care.vo.result.PatientBindOutputVO;

import java.util.Comparator;
import java.util.List;

/**
 * @author: zqb
 * @date: 2024/10/29 09:02
 */
@Slf4j
@RequiredArgsConstructor
@Validated
@RestController
@RequestMapping("/bFuerPatient")
@Tag(name = "妇儿医院患者信息接口")
public class BPatientFuerController {

    private final BDevBindService bindService;

    private final BPatientService bPatientService;

    @Operation(summary = "查询病人首页数据-妇儿医院")
    @GetMapping("/home")
    public R<List<FuerInpatientInfoResult>> selectPatientsHomePage() {
//        List<FuerInpatientInfoResult> list;
//        TestWebservice testWebservice = new TestWebservice();
//
//        list = testWebservice.analysisData();
//
//        for (int i = 0; i < list.size(); i++) {
//            FuerInpatientInfoResult fuerInpatientInfoResult=list.get(i);
//            PatientBindInputVO patientBindInputVO=new PatientBindInputVO();
//            patientBindInputVO.setHospitalNumber(fuerInpatientInfoResult.getInpatientId());
//            patientBindInputVO.setPatientIdent(fuerInpatientInfoResult.getPatientId());
//
//            List<PatientBindOutputVO> patientBindOutputVO = bindService.queryPatientBindHome(patientBindInputVO);
//            fuerInpatientInfoResult.setPatientBindOutputVO(patientBindOutputVO);
//        }

        TestWebservice testWebservice = new TestWebservice();
        //webservice数据
        List<FuerInpatientInfoResult> list;
        list = testWebservice.analysisData();
        List<FuerInpatientInfoResult>  fuerInpatientInfoResults=bPatientService.getHomePatients(list);
        fuerInpatientInfoResults.sort(Comparator.comparing(FuerInpatientInfoResult::getBedNo));

        return R.success(fuerInpatientInfoResults);
    }

    @Operation(summary = "测试webservice返回内容-妇儿医院")
    @GetMapping("/test/getwebserviceContent")
    public R<String> getWebserviceContent(PatientHomePageQueryVO queryVO) {

        TestWebservice testWebservice = new TestWebservice();
        return R.success(testWebservice.getContent());
    }
}
